<!DOCTYPE html>
<html lang="cn">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style type="text/css">
        .container {
            width: 600px;
            margin: 0 auto;
            padding: 30px;
            background-color: #eef;
        }

        .price {
            font-size: 25px;
            color: #f00;
            font-family: 'monaco';
            font-weight: 900;
        }
    </style>
    {js href="/static/index/js/jquery.min.js"}
</head>
<body>
<div class="container">
    <h1>BTC 行情</h1>
    <hr>
    <ul id="btc"></ul>
</div>

<script>
    $(function () {
        getAJAX();
        setInterval(getAJAX, 5000);

        function getAJAX() {
            $.ajax({
                type: 'get',
                url: "{:url('index/btc/getPrices')}",
                dataType: 'json',
                success: function (data) {
                    console.log(data);
                    $('#btc').empty();
                    for (var i in data) {
                        $("<li>", {
                            "class": "price",
                            text: i + data[i].buy.toFixed(2) + data[i].symbol
                        }).appendTo('#btc');
                    }
                }
            });
            $('#btc').slideToggle(5000);
        }
    });

</script>
</body>
</html>